% cmds2.tex
\centerline{\bf Jacal commands available at top level}\vskip.25in
\par\noindent
${\bf\%}$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&The symbol ${\bf\%}$ represents the last expression obtained by Jacal. It can\cr
&be used in formulas like any other constant or variable or expression.\cr
&\cr}
\begintt
          e21: 5

          e22 : %;

          e22: 5

          e23 : %^2;

          e23: 25
\endtt
$<expr_1>*<expr_2>$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&Multiplication of scalar expressions such as numbers, polynomials, rational\cr
&functions and algebraic functions is denoted by the infix operator $*$. For\cr
&example,\cr
&\cr}
\begintt
          e1 : (2+3*a)*4*a*b^2;
          
                         2   2
          e1: (8 a + 12 a ) b
\endtt
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&One can also use $*$ as an infix operator on bunches. In that case, it\cr
&operates componentwise, in an appropriate sense. In case the bunches are\cr
&square matrices, the operator $*$ multiplies corresponding entries of the\cr
&two factors. It does not perform matrix multiplication. To multiply matrices\cr
&one instead uses the operator \ {\bf.}\ (i.e. a period). More generally, any binary\cr
&scalar operator other than {\bf\^{}} can be used on bunches and acts componentwise.\cr
&\cr}
$<matrix_1>{\bf.}<matrix_2>$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&Matrix multiplication. \cr}
\begintt
e1 : a:[[1,2,3],[5,2,7]];

    [1  2  3]
e1: [       ]
    [5  2  7]

e2 : b:[[3,2],[6,4]];

    [3  2]
e2: [    ]
    [6  4]

e3 : b.a;

    [13  10  23]
e3: [          ]
    [26  20  46]

\endtt
$<expr_1>+<expr_2>$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&Addition of scalar quantities or componentwise addition of bunches is accomplished\cr
&by means of the infix operator $+$. For example,\cr
&\cr}
\begintt
          e2 : a:[[1,3,5],[2,4,7]];
          
              [1  3  5]
          e2: [       ]
              [2  4  7]
          
          e3 : b:[2,4];
          
          e3: [2 , 4]
          
          e4 : a+b;
          
              [3  5  7 ]
          e4: [        ]
              [6  8  11]
          
          e5 : 3+2;
          
          e5: 5
          
          e6 : c+b;
          
          e6: [2 + c , 4 + c]
          
          e7 : e1+e5;
          
                             2   2
          e7: 5 + (8 a + 12 a ) b
\endtt
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr}
$<expr_1>-<expr_2>$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The symbol $-$ is used to denote either the binary infix operator subtraction\cr
&or the unary minus. \cr
&\cr}
\begintt
         e1 : -[1,2,3];
         
         e1: [-1 , -2 , -3]
         
         e2 : 3-7;
         
         e2: -4
\endtt
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr}
$<expr_1>\pm<expr_2>$\par\noindent
$<expr_1>\mp<expr_2>$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&Jacal allows the use of $\bf\pm$ and $\bf\mp$ as ambiguous signs\cr
&(unary plus-or-minus, unary minus-or-plus) and as ambiguous infix\cr
&operators (binary plus-or-minus, binary minus-or-plus). The value $\pm1$\cr
&is also represented by the constant {\bf\%sqrt1}, while $\mp1$ is represented by\cr
&$\bf-\%sqrt1$.\cr
&\cr}
\begintt
         e7 : u:+/-3;

         e7: 3 %sqrt1

         e8 : u^2;

         e8: 9

         e9 : +/-(u);

         e9: 3

         e10 : u-/+3;

         e10: b-/+(3 %sqrt1, 3)

\endtt
$<expr_1>/<expr_2>$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The symbol for division in Jacal is $/$. For example, the value returned by\cr
&$6/2;$ is 3.\cr}
\begintt
         e3 : (x^2-y^2)/(x-y);
          
         e3: x + y
\endtt
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr}
$<expr_1>\ =\ <expr_2>$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&In Jacal, the equals sign $\bf=$ is {\bf not} used for conditionals and  it\cr
&is {\bf not} used for assignments. To assign one value to another, use\cr
&either $:$ or $:=$. The operator  $=$ merely returns a value of the form\cr
&$0=<expression>$. The value returned by $a=b$ for example is $0=a-b$.\cr 
&\cr}
\begintt
          e6 : 1=2;

          e6: 0 = -1

\endtt
$<expr_1>${\bf\ \^{}\ }$<expr_2>$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The infix operator {\bf\^{}} is used for exponentiation of scalar quantitites or\cr
&for componentwise exponentiation of bunches. For example, $2^5$ returns 32.\cr
&Unlike the other scalar infix operators, one cannot use {\bf\^{}} for component-\cr
&wise operations on bunches. Furthermore, one should not try to use {\bf\^{}} to\cr
&raise a square matrix to a power. Instead, one should use {\bf\^{}\^{}}\cr
&\cr}
\begintt
          e7 : (1+x)^4;

                           2      3    4
          e7: 1 + 4 x + 6 x  + 4 x  + x

\endtt
$<matrix>${\bf\ \^{}\^{}\ }$<int>$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The infix operator {\bf\^{}\^{}} is used for raising a square matrix\cr
&to an integral power.It can also be used on nonsquare matrices, but the results\cr
&are not documented.\cr
&\cr}
\begintt
          e8 : a:[[1,0],[-1,1]];

              [1   0]
          e8: [     ]
              [-1  1]

          e9 : a^^3;

              [1   0]
          e9: [     ]
              [-3  1]

\endtt
{\bf batch($<filename>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf batch} is used to read in a file containing programs written\cr
&in Jacal. Here, $<filename>$ is a string in double quotes. The precise way in which\cr
&one refers to a file is of course system dependent.\cr
&\cr}
\begintt
          e18 : system("ex pluses");
          e18 : system("ex pluses");
          "pluses" 3 lines, 19 characters
          :1,$d
          :a
          w:2;
          x:5;
          w^x-x^w;
          .
          :wq
          "pluses" 3 lines, 19 characters

          e18: 0

          e19 : batch("pluses");

          e20 : 
          e20: 2

          e21 : 
          e21: 5

          e22 : 
          e22: 7

          e23 : e19 : 

\endtt\par\noindent
{\bf bunch($<elt_1>,\ <elt_2>,\dots,\ <elt_n>$)}\par\noindent
$\bf[<elt_1>,\ <elt_2>,\dots,\ <elt_n>]$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&To collect any number of Jacal objects into a bunch, simply enclose them in\cr
&square brackets. For example, to make the bunch whose elements are 1,2,4, type\cr
&$[1,2,4]$. One can also nest bunches, for example, $[1,[[1,3],[2,5]],[1,4]]$.\cr
&Note however that the bunch whose only element is $\bf[1,2,3]$ is $\bf[1\ 2\ 3]$.\cr
&It is importance to notice that one has commas and the other doesn't.\cr
&\cr}\noindent
\begintt
          e3 : a:bunch(1,2,3);

          e3: [1 , 2 , 3]

          e4 : b:[a];

          e4: [1  2  3]

          e5 : c:[b];

          e5: [[1 , 2 , 3]]

          e6 : [[[1,2,3]]];

          e6: [[1 , 2 , 3]]

\endtt
{\bf coeff($<poly>,<var>$);}\par\noindent
{\bf coeff($<poly,var,deg>$);}\par\noindent
{\bf coeffs($<poly,var>$);}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf coeff} is used to determine the coefficient of a certain power\cr
&of a variable in a given polynomial. Here {\bf poly} is a polynomial and {\bf var}\cr
&is a variable. If the optional third argument is omitted, then Jacal returns\cr
&the coefficient of the variable {\bf var} in {\bf poly}. Otherwise it returns\cr
&the coefficient of $\bf var^{deg}$ in {\bf poly}. The functions {\bf coeffs}\cr
&returns a list of all of the coefficients. For example,\cr
&\cr}
\begintt
          e14 : coeff((x+2)^4,x,3);

          e14: 8

          e15 : (x+2)^4;

                               2      3    4
          e15: 16 + 32 x + 24 x  + 8 x  + x

          e16 : coeff((x+2)^4,x);

          e16: 32

          e18 : coeffs((x+2)^4,x);

          e18: [16 , 32 , 24 , 8 , 1]

\endtt
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&The function {\bf poly} provides an inverse to the function {\bf coeffs},\cr
&allowing one to recover a polynomial from its list of coefficients.\cr
&\cr}
{\bf col($<matrix>,<integer>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf col} is used to extract a column of a matrix. Here,\cr
&$<matrix>$ is a matrix and $<integer>$ is a positive integer. If that\cr
&integer exceeds the number of columns, an error message such as\cr
&\cr
&{\bf ERROR: list-ref: Wrong type in arg1 ()}\cr
&\cr
&appears. Here is an example of correct use of the command {\bf col}:\cr
&\cr}
\begintt
e19 : a:[[1,2,4],[2,5,6]];
          
               [1  2  4]
          e19: [       ]
               [2  5  6]

          e20 : col(a,2);

               [2]
          e20: [ ]
               [5]
\endtt
{\bf commands()}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf commands} produces a list of all of the command available in\cr
&Jacal. It is called as s function of no arguments. Explicitly:\cr
&\cr
&{\bf e11 : commands();}\cr
&\cr}
\begintt
e21 : commands();

     u-/+ u+/- transpose transcript differential terms system sylvester
     show set scalarmatrix row resultant rapply quit qed poly_discriminant poly
     or num negate mod minor matrix load listofvars ident genmatrix gcd finv
     factor example eliminate dotproduct divide diff diagmatrix determinant
     describe denom crossproduct content commands col coeffs coeff bunch batch
     b+/- ^^ ^ = / - + * %

\endtt
{\bf content($<poly>,<var>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&Returns a list of content and primitive part of a polynomial with\cr
&respect to the variable.  The content is the GCD of the coefficients\cr
&of the polynomial in the variable.  The primitive part is $<poly>$ divided\cr
&by the content\cr
&\cr}
\begintt

          e24 : content(2*x*y+4*x^2*y^2,y);

                               2
          e24: [2 x , y + 2 x y ]
\endtt
{\bf crossproduct($<vector_1>,<vector_2>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The Jacal command {\bf crossproduct} computes the cross product of two vectors.\cr
&By definition, the two vectors must each have three components.\cr
&\cr}
\begintt
          e24: [2 x , y + 2 x y ]

          e25 : crossproduct([1,2,3],[4,2,5]);

          e25: [4 , 7 , -6]

\endtt
{\bf denom($<rational\ expression>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The Jacal command {\bf denom} is used to obtain the denominator of a rational\cr
&expression. \cr
&\cr}
\begintt
          e26 : denom(4/5);

          e26: 5

\endtt
{\bf describe($<command>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf describe} is the heart of the online help facility of Jacal.\cr
&Here,  $<command>$ is a string which is the name of a command and {\bf describe}\cr
&produces a brief description of the command and in many cases includes\cr
&an example of its use. Together with the command {\bf commands()}, which prints\cr
&a list of all available Jacal commands, and the command {\bf example}, which\cr
&gives an example of the use of the command, one can in principle use Jacal without\cr
&a manual after one has learned how to get started.\cr
&\cr}
\begintt
          e27 : describe(col);
          column.  column of a matrix
          e27 : describe(resultant);
          resultant.  The result of eliminating a variable between 2
          equations (or polynomials).
          e27 : describe(+);
          Addition, plus.
          a + b

\endtt
{\bf determinant($<matrix>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The Jacal command {\bf determinant} computes the determinant of a square matrix.\cr
&Attempting to take the determinant of a non-square matrix will produce an error\cr
&message.\cr
&\cr}
\begintt
          e1 : a:[[1,2],[6,7]];

              [1  2]
          e1: [    ]
              [6  7]

          e2 : determinant(a);

          e2: -5

\endtt
{\bf diagmatrix($<list>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The Jacal command {\bf diagmatrix} takes as input a list of\cr
&objects and returns the diagonal matrix having those objects\cr
&as diagonal entries. In case one wants all of the diagonal entries\cr
&to be equal, it is more convenient to use the command {\bf scalarmatrix}.\cr
&\cr}
\begintt
          e3 : diagmatrix(12,3,a,s^2);

              [12  0  0  0 ]
              [            ]
              [0   3  0  0 ]
          e3: [            ]
              [0   0  a  0 ]
              [            ]
              [0   0  0   2]
              [          s ]

          e4 : diagmatrix([1,2],2);

              [[1 , 2]  0]
          e4: [          ]
              [   0     2]

\endtt
{\bf divide($<dividend>,<divisor>,<var>$)}\par\noindent
{\bf divide($<dividend>,<divisor>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf divide} treats {\bf dividend} and {\bf divisor} as polynomials\cr
&in the variable {\bf var} and returns a pair $\bf[quotient,remainder]$ such that\cr
&$\bf dividend=divisor*quotient+remainder$. If the third argument $<var>$ is omitted\cr
&Jacal will choose a variable on its own with respect to which it will do the\cr
&division. In particular, of $<dividend>$ and $<divisor>$ are both numerical, one\cr
&can safely omit the third argument.\cr
&\cr}
\begintt
         e5 : divide(x^2+y^2,x-7*y^2,x);

                     2    2       4
         e5: [x + 7 y  , y  + 49 y ]

         e6 : divide(-7,3);

         e6: [-2 , -1]

         e11 : divide(x^2+y^2+z^2,x+y+z);

                                2              2
         e11: [- x - y + z , 2 x  + 2 x y + 2 y ]

         e14 : divide(x^2+y^2+z^2,x+y+z,y);

                                2              2
         e14: [- x + y - z , 2 x  + 2 x z + 2 z ]

         e15 : divide(x^2+y^2+z^2,x+y+z,z);

                                2              2
         e15: [- x - y + z , 2 x  + 2 x y + 2 y ]

\endtt
{\bf dotproduct($<vector_1,vector_2>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The Jacal function {\bf dotproduct} returns the dot product of two row vectors\cr
&of the same length. It will also give the dot product of two matrices of the\cr
&same size by computing the sum of the dot products of the corresponding\cr
&rows or, what is the same, the trace of one matrix times the transpose of\cr
&the other one.\cr
&\cr}
\begintt
        e28 : a:[1,2,3]; b:[3,1,5];

        e28: [1 , 2 , 3]

        e29 : 
        e29: [3 , 1 , 5]

        e30 : dotproduct(a,b);

        e30: 20

\endtt
{\bf eliminate($[<eqn_1>,<eqn_2>,\dots,<eqn_n>],[<var_1>,<var_2>,\dots,<var_m>]$);}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&Here $<eqn_i>$ is an equation for $i=1,\dots, n$ and where $<var_j>$ is a variable\cr
&for $j=1,\dots,m$. {\bf eliminate} returns a list of equations obtained by eliminating the\cr
&variables $<var_1>,dots,<var_m>$ from the equations $<eqn_1>,\dots,<eqn_n>$.\cr
&\cr}
\begintt

       e39 : eliminate([x^2+y=0,x^3+y=0],[x]);

                       2
       e39: 0 = - y - y

       e40 : eliminate([x+y+z=3,x^2+y^2+z^2=3,x^3+y^3+z^3=3],[x,y]);

       e40: 0 = 1 - z

\endtt
{\bf example($<command>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&Here, $<command>$ is a string which is the name of a Jacal command. {\bf example}\cr
&{\bf example} gives an example of the use of the command. See also the function {\bf describe}\cr
&\cr
\begintt

       e43 : example(+);
       a + b


       e43: a + b

\endtt
&\cr}
{\bf factor($<int>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The Jacal command {\bf factor} takes as input an integer and returns\cr
&a list of the prime numbers that divide it, each occurring with the appropriate\cr
&multiplicity in the list. If the number is negative, the list will begin\cr
&with $-1$.\cr}
\begintt

       e45 : factor(120);

       e45: [2 , 2 , 2 , 3 , 5]

       e46 : factor(-120);

       e46: [-1 , 2 , 2 , 2 , 3 , 5]

\endtt
{\bf finv($<function>$)}\par\noindent
$<function>${\bf\^{\ }\^{\ }-1}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf finv} takes as input a function of one variable\cr
&and returns the inverse of that function. The function may be defined\cr
&in any of the ways permitted in Jacal, i.e. by an explicit algebraic\cr
&definition, by an explicit lambda expression or by an implicit lamba\cr
&expression. If $f$ is the function, then typing $f${\bf\^{\ }\^{\ }-1} has\cr
&the same effect as typing {\bf finv(f)}.\cr
&\cr}
\begintt
e0 : w(t):=t+1;

w(t): lambda([@1], 1 + @1)

e0 : finv(w);

e0: lambda([@1], -1 + @1)
\endtt
{\bf gcd($<poly_1>,<poly_2>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The Jacal function {\bf gcd} takes as arguments two polynomials with integer\cr
&coefficients and returns a greatest common divisor of the two polynomials. This\cr
&includes the case where the polynomials are integers.\cr
&\cr}
\begintt
e1 : gcd(x^4-y^4,x^6+y^6);

     2    2
e1: x  + y

e2 : gcd(4,10);

e2: 2

\endtt
{\bf genmatrix($<function>,<rows>,<cols>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&The function {\bf genmatrix} takes as arguments a function $<function>$ of two\cr
&variables and two positive integers, $<rows>$ and $<cols>$. It returns a\cr
&matrix with the indicated numbers of rows and columns in which the $(i,j)$th\cr
&entry is obtained by evaluating $<function>$ at $(i,j)$. The function may be\cr
&defined in any of the ways available in Jacal, i.e previously by an explicit\cr
&algebraic definition, by an explicit lambda expression or by an implicit lambda\cr
&expression.\cr
&\cr}
\begintt
e4 : @1^2+@2^2;

                        2     2
e4: lambda([@1 , @2], @1  + @2 )

e5 : genmatrix(e4,3,5);

    [2   5   10  17  26]
    [                  ]
e5: [5   8   13  20  29]
    [                  ]
    [10  13  18  25  34]

\endtt
{\bf ident($n$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf ident} takes as argument a positive integer $n$\cr
&and returns an $n\times n$ identity matrix. This is sometimes more convenient\cr
&than obtaining this same matrix using the command {\bf scalarmatrix}.\cr
&\cr}
\begintt

e6 : ident(4);

    [1  0  0  0]
    [          ]
    [0  1  0  0]
e6: [          ]
    [0  0  1  0]
    [          ]
    [0  0  0  1]

\endtt
{\bf lambda([$<varlist>,<algebraic\ expression>$])}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&Jacal has the ability to work with lambda expressions, via the command\cr
&{\bf lambda}. Furthermore, Jacal always converts user definitions of functions\cr
&by any method into lambda expressions and converts the dummy variables of the\cr
&function definition into symbols such as {\bf @1,@2},\dots. Jacal can manipulate\cr
&lambda expressions by manipulating their function parts, as in {\bf e14} below.\cr
&Jacal can also invert a function using the command {\bf finv}.\cr}
\begintt

e12 : lambda([x],x^2);

                    2
e12: lambda([@1], @1 )

e13 : lambda([x,y,z],x*y*z);

e13: lambda([@1, @2, @3], @1 @2 @3)

e14 : e12+e13;

                            2
e14: lambda([@1, @2, @3], @1  + @1 @2 @3)

\endtt
{\bf listofvars($<expr>$}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf listofvars} takes as input a rational expression and returns\cr
&a list of the variables that occur in that expression.\cr
&\cr}
\begintt

e7 : listofvars(x^2+y^3);

e7: [x , y]

e8 : listofvars((x^2+y^3)/(2*x^7+y*x+z));

e8: [z , x , y]

\endtt
{\bf load($<string>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The jacal command {\bf load} takes as input a string and reads in a {\bf scm} file\cr
&whose name is obtained by appending the extension {\bf.scm} to the string.\cr
&If you want to read in a file of Jacal commands, do not use {\bf load}. Instead\cr
&use the command {\bf batch}. To load in the file {\bf foo.scm},\cr
&\cr}
\begintt
e9 : load("foo");

e9: foo

\endtt
$\bf minor(<matrix>,<row>,<col>);$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf minor} returns the submatrix of $<matrix>$ obtained by\cr
&deleting the $i$th row and the $j$th column, where $i=<row>$ and $j=<col>$.\cr
&\cr}\noindent
\begintt

e21 : b:[[1,2,3],[3,1,5],[5,2,7]];

     [1  2  3]
     [       ]
e21: [3  1  5]
     [       ]
     [5  2  7]

e22 : minor(b,3,1);

     [2  3]
e22: [    ]
     [1  5]

\endtt
{\bf mod($<int>,<modulus>$)}\par\noindent
{\bf mod($<polynomial>,<equation>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The function {\bf mod} takes as inputs two integers and returns the\cr
&an integer which is congruent to the first modulo the second. It can\cr
&also reduce a polynomial with respect to a given equation.\cr
&\cr}
\begintt

e23 : mod(5,2);

e23: -1

e24 : mod(x^4+4,x^2=2);

e24: 8

\endtt
{\bf num($<expr>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The function {\bf num} takes a rational expression as input and returns a\cr
&numerator of the expression.\cr
&\cr}
\begintt

e25 : num((x^2+y^2)/(x^2-y^2));

        2    2
e25: - x  - y

e26 : num(7/4);

e26: 7

e27 : num(7/(4/3));

e27: 21

\endtt
{\bf or($<expr_1>,<expr_2>$)}\par\noindent
{\bf or($<eqn_1>,<eqn_2>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The function {\bf or} takes as inputs either two equations or two values. If the\cr
&inputs are two equations, then {\bf or} returns an equation which is equivalent\cr
&to the assertion that at least one of the two input equations holds. If the\cr
&inputs to {\bf or} are two values instead of two equations, then the function\cr
&{\bf or} returns a multiple value. If the inputs to {\bf or} consist of\cr
&one equation and one value, then {\bf or} will return the value.\cr
&\cr}
\begintt
e1 : or(x=2,y=3);

e1: 0 = -6 + 3 x + (2 - x) y

e2 : or(2,3);

                            2
e2: {:@ | 0 = -6 + 5 :@ - :@ }

e3 : e2^2;

                              2
e3: {:@ | 0 = -36 + 13 :@ - :@ }

e4 : or(x=2,17);

e4: 17

\endtt
{\bf poly\b{\ }discriminant($<poly>,<var>$);}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&Here $<poly>$ is a polynomial and $<var>$ is a variable.  This function returns\cr
&the square of the product of the differences of the roots of the polynomial $<poly>$\cr
& with respect to the variable $<var>$.\cr
&\cr}
\begintt
e7 : poly_discriminant(x^3-1,x);

e7: -27

\endtt
{\bf qed()}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf qed();} is probably the most important command you need to know\cr
&when using Jacal, since it is the command that let's you exit from Jacal. It \cr
&does not however, return you to the operating system. Instead it suspends Jacal\cr
&and returns you to the underlying lisp. You can return to the Jacal session where\cr
&you left off by simply typing {\bf (math)}.This allows you to do some programming\cr
&in the underlying lisp before returning to Jacal. If you do not wish to return to\cr
&Jacal but really want to terminate the session and return to the operating system,\cr
&then after typing {\bf qed();}, you must then type whatever command is used to\cr
&exit from the underlying lisp to the operating system. In {\bf scm}, the command\cr
&is {\bf(quit)}. If the underlying lisp uses the command {\bf (quit)} to return\cr
&to he operating system, then one can exit directly from Jacal to the operating\cr
&system without using {\bf qed();} by simply typing {\bf quit();}.\cr
&\cr}
\begintt
unix>jacal

JACAL version 1a0, Copyright 1989, 1990, 1991, 1992 Aubrey Jaffer
JACAL comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `(terms)' for details.
;;; Type (math) to begin.
> (math)
type qed()
 to return to scheme
e1 : qed();
scheme
> (quit)
unix>jacal

JACAL version 1a0, Copyright 1989, 1990, 1991, 1992 Aubrey Jaffer
JACAL comes with ABSOLUTELY NO WARRANTY; for details type `(terms)'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `(terms)' for details.
;;; Type (math) to begin.
> (math)
type qed()
 to return to scheme
e1 : qed();
scheme
> (math)
type qed()
 to return to scheme
e2 : quit();
unix>

\endtt
{\bf quit()}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&See: {\bf qed}\cr
&\cr}
{\bf rapply$(<bunch>,<int_1>,<int_2>,\dots,<int_n>);$}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The function {\bf rapply} is used to access elements of bunches. It can also\cr
&access elements nested at lower levels in a bunch. In particular, it can also\cr
&access matrix elements. In the above syntax, $<bunch>$ is the bunch whose parts\cr
& one wishes to access, and $n,<int_1>,<int_2>,\dots,<int_n>$ are positive integers.\cr
&It returns the $<int_n>$-th elementof the $<int_{n-1}>$-th element of \dots of the\cr
&$<int_2>$-th element of the $<int_1>$-th element of $<bunch>$. One can have $n=0$. \cr
&In that case, {\bf rapply} simply returns the bunch.\cr
&\cr}
\begintt
e2 : rapply([[1,2,3],[1,4,6],3],2,3);

e2: 6

e6 : rapply([a,b],2);

e6: b

e7 : rapply([a,b]);

e7: [a, b]

\endtt
{\bf resultant($<poly_1>,<poly_2>,<var>$);}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The function {\bf resultant}  returns the resultant of the polynomials \cr
&$<poly_1>$ and $<poly_2>$ with respect to the variable $<var>$.\cr
&\cr}
\begintt
e2 : resultant(x^2+a,x^3+a,x);

     2    3
e2: a  + a

\endtt
{\bf row($<matrix>,<int>$);}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf row} returns the $i$th row of the matrix $<matrix>$, where $i=<int>$.\cr
&If $<int>$ is larger than the number of rows of $<matrix>$, then Jacal prints\cr
&an error message. The corresponding command for columns of a matrix is {\bf col}.\cr
&\cr}
\begintt
e3 : u:[[1,2,3],[1,5,3]];

    [1  2  3]
e3: [       ]
    [1  5  3]

e4 : row(u,2);

e4: [1, 5, 3]

\endtt
{\bf scalarmatrix($<size>,<entry>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&The command {\bf scalarmatrix} takes as inputs a positive integer\cr
&$<size>$ and an algebraic expression $<entry>$ and returns an $n\times n$\cr
&diagonal matrix whose diagonal entries are all equal to $<entry>$, where\cr
&$n=\ <size>$.\cr}
\begintt

e1 : scalarmatrix(3,6);

    [6  0  0]
    [       ]
e1: [0  6  0]
    [       ]
    [0  0  6]

\endtt
{\bf set $<flag>$ $<value>$}\par\noindent
{\bf set ingrammar $<grammar>$}\par\noindent
{\bf set outgrammar $<grammar>$}\par\noindent
{\bf set priority $<int>$}\par\noindent
{\bf set prompt $<string>$}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&There are various flags that the Jacal user can control, namely the Jacal\cr
&command line prompt, the priority for printing terms in Jacal output, the input\cr
&grammar and the output grammar. For a discussion\cr
&of the various grammars please see section ??? of this manual. The command {\bf show}\cr
&is closely related, allowing one to see what the current settings are.\cr
&If one changes the prompt, $<string>$ is a string of alphanumeric characters\cr
&without quotes. After this command is executed, subsequent commands will cuase\cr
&new prompts to be obtained from $<string>$ by incrementing it. If the prompt\cr
&ends in a letter, it will be treated as a digit in base 26 and incremented.\cr
&If it ends in a string of digits, that string will be treated as a number in base\cr
&10 and incremented.\cr
&The remaining characters in the string will play no role in this incrementation.\cr
&\cr}
\begintt
e1 : set prompt az9Z;
e1 : a+b;

az9Z: a + b

az9AA : a+b;

az9AA: a + b

az9AB : set prompt ok99;
az9AB : a+b;

ok99: a + b

ok100 : a+b;

ok100: a + b

ok101 : 

\endtt
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&The following examples show how one changes the input grammar or the\cr
&output grammar.\cr
&\cr}
\begintt
e1 : a:[[[1,2,3]]];

e1: [[1, 2, 3]]

e2 : set outgrammar standard;
e2 : a;

e2: [[[1, 2, 3]]]

e3 : set outgrammar scheme;
e3 : a;

(define e3 #(#(#(1 2 3))))
e4 : (1+x)^5;

(define e4 (+ 1 (* 5 x) (* 10 (^ x 2)) (* 10 (^ x 3)) (* 5 (^ x 4)) (^ x 5)))
e6 : set ingrammar scheme;
e6 : (+ e4 1);

(define e6 (+ 2 (* 5 x) (* 10 (^ x 2)) (* 10 (^ x 3)) (* 5 (^ x 4)) (^ x 5)))
e7 : (set ingrammar disp2d)
e7 : diagmatrix(3,6);

(define e7 #(#(3 0) #(0 6)))
e8 : set outgrammar disp2d;
e8 : e7;

    [3  0]
e8: [    ]
    [0  6]

e9 : set outgrammar standard;
e9 : e7;

e9: [[3, 0], [0, 6]]

\endtt
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&Note that in the above examples, it is possible to input and output expressions\cr
&in scheme by setting the ingrammar and/or outgrammar to {\bf scheme}. Doing so result\cr
&in linear output (as with {\bf standard grammar}) as opposed to a two dimensional\cr
&display (as with {\bf disp2d}). The analogue of {\bf disp2d} for scheme output\cr
&is scheme prettyprinting. To have such output, set the output grammar to\cr
&{\bf schemepretty}.\cr
&\cr}
\begintt

e4 : set outgrammar schemepretty;
e4 : (1+x)^5;

(define e4
  (+ 1
     (* 5 x)
     (* 10 (^ x 2))
     (* 10 (^ x 3))
     (* 5 (^ x 4))
     (^ x 5)))

\endtt
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&Jacal also allows for output to be automatically typeset in \TeX. This can be\cr
&quite useful if one wants to use the results of one's computations in published\cr
&articles. Continuing with the example of $(1+x)^5$ above, we have.\cr
&\cr}
\begintt

e5 : set outgrammar tex;
e5 : e4;

e5: 1 + 5 x + 10 x^{2} + 10 x^{3} + 5 x^{4} + x^{5}

e6 : (1+1/x)^3/(1-1/y)^4;

e6: {\left(1 + 3 x + 3 x^{2} + x^{3}\right) y^{4}}\over{x^{3} - 4 x^{3} y + 

                6 x^{3} y^{2} - 4 x^{3} y^{3} + x^{3} y^{4}}

\endtt
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&After being included in a document in math display mode, these two examples\cr
&will appear in the following way.\cr
&\cr}
$$ 1 + 5 x + 10 x^{2} + 10 x^{3} + 5 x^{4} + x^{5}$$
$${\left(1 + 3 x + 3 x^{2} + x^{3}\right) y^{4}}\over{x^{3} - 4 x^{3} y + 
                6 x^{3} y^{2} - 4 x^{3} y^{3} + x^{3} y^{4}}$$
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&That looks much better in an article than the actual Jacal output in {disp2d}\cr
&grammar.\cr
&\cr}
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&The following examples show how to set the priority of printing terms.\cr}
\begintt
e10 : a;

e10: [[[1, 2, 3]]]

e11 : show priority a;

;;; not a simple variable:  (((1 2 3) . ()) . ())

e12 : show priority b;

e12: 128

e13 : show priority c;

e13: 128

e14 : b+c;

e14: b + c

e15 : c+b;

e15: b + c

e16 : set priority b 200;
e16 : b+c;

\endtt
{\bf show $\{     prompt\mid\ priority\mid\ outgrammar\mid\ ingrammar\mid\ grammars\mid\ all\}$}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&The command {\bf show} enables the Jacal user to examine the current setting\cr
&of various flags as well as to list the flags that can be set by the user and\cr
&to display other information. To change the settings of the flags, use the command\cr
&{\bf set}. To see all the information accessible through the {\bf show} command,\cr
&type {\bf show all}. To see the available grammars, type {\bf show grammars}.\cr
&To see the current input grammar type {\bf show ingrammar}. To see the current\cr
&output grammar, type {\bf show outgrammar}. To see the current priority for\cr
&printing expressions, type {\bf show priority}.\cr
&\cr}
\begintt
e1 : show all;

     prompt priority outgrammar ingrammar grammars all
e1 : show prompt;

e1: e1

e3 : show priority;

     :@ (differential :@) @3 @2 @1 %inftsl y x u-/+ u+/- transpose transcript
     differential terms t system sylvester showpriority show set
     scalarmatrix row resultant rapply quit qed prompt priority
     poly_discriminant poly or num negate mod minor matrix load listofvars
     ident genmatrix gcd finv factor example eliminate e1 dotproduct divide
     diff diagmatrix determinant describe denom crossproduct content commands
     col coeffs coeff c bunch batch b-/+ b+/- b all a ^^ ^ = / - + * % %sqrt1
     %i
e3 : show outgrammar;

e3: disp2d

e4 : show ingrammar;

e4: standard

e5 : show grammars;

e5: [disp2d, standard, schemepretty, scheme]

\endtt
{\bf sylvester($<poly_1>,<poly_2>,<var>$);}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&Here, $<poly_1>$ and $<poly_2>$ are polynomials and $<var>$ is a variable.\cr
&The function {\bf sylvester} returns the matrix introduced by Sylvester (``A\cr
&Method of Determining By Mere Inspection the Derivatives from Two Equations\cr
&of Any Degree,'' Phil.Mag. {\bf 16} (1840) pp.132-135, Mathematical Papers,\cr
&vol.I, pp.54-57) for computing the resultant of the two polynomials\cr
&$<poly_1>$ and $<poly_2>$ with respect to the variable $<var>$. If one wants\cr
&to compute the resultant itself, one can simply use the command {\bf resultant}\cr
&with the same syntax.\cr
&\cr}
\begintt
e5 : sylvester(a0+a1*x+a2*x^2+a3*x^3,b0+b1*x+b2*x^2,x);

    [a3  a2  a1  a0  0 ]
    [                  ]
    [0   a3  a2  a1  a0]
    [                  ]
e5: [b2  b1  b0  0   0 ]
    [                  ]
    [0   b2  b1  b0  0 ]
    [                  ]
    [0   0   b2  b1  b0]

\endtt
{\bf system($<command>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&One can issue commands to the operating system without leaving Jacal. To do this,\cr
&one uses the command {\bf system}. For example, in a UNIX operating system, the\cr
&command {\bf system(``ls'');} will print the directory. One way in which the\cr
&command {\bf system} might be especially useful is to edit files containing\cr
&Jacal scripts without leaving Jacal, particularly in non-UNIX machines or on\cr
&machines without GNU emacs.\cr
&\cr}
\begintt
e6 : system("mail irmentrude");

Hi Irma, how are you?

Lancelot
.

e6: 0

e7 : system("ex gleep");
"gleep" 26 lines, 239 characters
:a
.
:1,$
COPYING
ChangeLog
MANUAL
Makefile
OLD
README
TAGS
builtin.scm
code.doc
compilem.lisp
ext.scm
func.scm
hist.scm
math.lisp
math.scm
norm.scm
parse.scm
poly.scm
scl.lisp
scl.scm
sexp.scm
stdgrm.scm
toploads.scm
types.scm
unparse.scm
vect.scm
:a

test.scm
.
:wq
"gleep" 28 lines, 249 characters

e7: 0

\endtt
{\bf terms()}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&Prints a copy of the GNU General Public License\cr
&\cr}
\begintt
e6 : terms();

e6 : terms();

GNU GENERAL PUBLIC LICENSE
**************************
                        Version 1, February 1989

     Copyright (C) 1989 Free Software Foundation, Inc.
     675 Mass Ave, Cambridge, MA 02139, USA

     Everyone is permitted to copy and distribute verbatim copies
     of this license document, but changing it is not allowed.


Preamble
========

  The license agreements of most software companies try to keep users
at the mercy of those companies.  By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software---to make sure the software is free for all its users.  The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
                  [ rest deleted for brevity]
\endtt
{\bf differential($<expr>$)}\par\noindent
$<expr>'$\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&The Jacal command {\bf differential} computes the derivative of the expression\cr
&$<expr>$ with respect to a generic derivation. It is generic in the sense that\cr
&nothing is assumed about its effect on the individual variables. The derivation\cr
&is denoted by a right quote.\cr
&\cr}
\begintt
e6 : differential(x^2+y^3);

                2
e6: 2 x x' + 3 y  y'

e7 : (x^2+y^3)';

                2
e7: 2 x x' + 3 y  y'

\endtt
{\bf transcript($<string>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf transcript} allows one to record a Jacal session. It is called\cr
&with the syntax {\bf transcript($<string>$);}, where $<string>$ is the name of\cr
&the file in which one wants to keep the transcript of the session. When one wishes\cr
&to stop recording, one types {\bf transcript();}. One is then free to use {\bf transcript}\cr
&again later in the session on another file. One can use it on the same file, but the\cr
&file is overwritten. Presently, the command {\bf transcript} does not echo commands\cr
&to a file. file.\cr
&\cr}
\begintt
e9 : a:[1,2,3];

e9: [1, 2, 3]

e10 : transcript("foo");

e10: foo

e11 : a;

e11: [1, 2, 3]

e12 : transcript();
e12 : system("cat foo");

e10: foo

e11 : a;

e11: [1, 2, 3]

e12 : transcript();

e12: 0

\endtt
{\bf transpose($<matrix>$)}\par\noindent
\halign{\quad\hskip.5truein#\hfil&\quad#\hfil\cr
&\cr
&The command {\bf transpose} takes a matrix as argument and returns the transpose\cr
&of the matrix.\cr
&\cr
}
\begintt
e13 : q:[[1,1,1,1,1],[1,2,3,4,5]];

     [1  1  1  1  1]
e13: [             ]
     [1  2  3  4  5]

e14 : transpose(e13);

     [1  1]
     [    ]
     [1  2]
     [    ]
e14: [1  3]
     [    ]
     [1  4]
     [    ]
     [1  5]

\endtt
\vfill\eject
\end
